/**
 * 用户登录日志js
 */

$(function () {
	initialPage();
	getGrid();
});

function initialPage() {
	$(window).resize(function() {
		$('#dataGrid').bootstrapTable('resetView', {height: $(window).height()-54});
	});
}

function getGrid() {
	$('#dataGrid').bootstrapTableEx({
		url: '/admin/loginOutLog/queryLoginOutLogPage?_' + $.now(),
		height: $(window).height()-54,
		queryParams: function(params){
			var queryData = {
					currentPage: params.pageNumber,
	                pageSize: params.pageSize,
	                keyword:vm.keyword
				};
			return queryData ;
		},
		detailView: false,
		//返回数据格式处理
        responseHandler: function(res) {
        	var code = res.code;
        	if(code == 0){
        		var result = res.result;
        		return {
        			"total": result.total,//总页数
        			"rows": result.data   //数据
        		};
        	}
        },
		columns: [{
			field : "module",
			title : "功能模块",
			width : "200px"
		}, {
			field : "function",
			title : "功能页面",
			width : "200px"
		}, {
			field : "loginName",
			title : "登录名",
			width : "200px"
		}, {
			field : "hostIp",
			title : "登录IP",
			width : "250px"
		}, {
			field : "operateType",
			title : "操作类型",
			width : "100px",
			formatter : function(value, row, index) {
				if (value == '0') {
					return '<span >新增</span>';
				} else if (value == '1') {
					return '<span >修改</span>';
				} else if (value == '2') {
					return '<span >删除</span>';
				} else if (value == '3') {
					return '<span >导入</span>';
				} else if (value == '4') {
					return '<span >导出</span>';
				} else if (value == '5') {
					return '<span >发送消息</span>';
				} else if (value == '6') {
					return '<span >审核</span>';
				} else if (value == '7') {
					return '<span >批量删除</span>';
				} else if (value == '8') {
					return '<span >移动</span>';
				} else if (value == '9') {
					return '<span>登录</span>';
				} else if (value == '10') {
					return '<span >退出登录</span>';
				} else if (value == '11') {
					return '<span >取消</span>';
				} else if (value == '12') {
					return '<span >置顶</span>';
				} else if (value == '13') {
					return '<span >上传</span>';
				} else if (value == '14') {
					return '<span >分享</span>';
				} else if (value == '15') {
					return '<span >回复</span>';
				} else if (value == '16') {
					return '<span >复制</span>';
				} else if (value == '17') {
					return '<span >查询</span>';
				} else {
					return '<span >其他</span>';
				}
			}
		}, {
			field : "operateContent",
			title : "操作内容",
			width : "400px"
		}, {
			field : "operateDate",
			title : "操作时间"
		}]
	})
}

var vm = new Vue({
	el:'#dpLTE',
	data: {
		keyword: null
	},
	methods : {
		load: function() {
			$('#dataGrid').bootstrapTable('refresh');
		}/*,
		remove: function() {
			var ck = $('#dataGrid').bootstrapTable('getSelections'), ids = [];	
			if(checkedArray(ck)){
				$.each(ck, function(idx, item){
					ids[idx] = item.id;
				});
				$.RemoveForm({
					url: '../../sys/log/remove?_' + $.now(),
			    	param: ids,
			    	success: function(data) {
			    		vm.load();
			    	}
				});
			}
		},
		clear: function() {
			$.ConfirmAjax({
				msg : "您确定要清空日志吗？",
				url: '../../sys/log/clear?_' + $.now(),
		    	success: function(data) {
		    		vm.load();
		    	}
			});
		}*/
	}
})